home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / Collections.h < prev    next >
Text File  |  1995-07-06  |  12KB  |  302 lines

  1. /*
  2.      File:        Collections.h
  3.  
  4.      Contains:    Collection Manager Interfaces.
  5.  
  6.      Version:    Technology:    Quickdraw GX 1.0
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __COLLECTIONS__
  21. #define __COLLECTIONS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MIXEDMODE__
  30. #include <MixedMode.h>
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_ALIGN_SUPPORTED
  38. #pragma options align=mac68k
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT_SUPPORTED
  42. #pragma import on
  43. #endif
  44.  
  45.  
  46. enum {
  47.     gestaltCollectionMgrVersion    = 'cltn'
  48. };
  49.  
  50. /* Collection Manager Error Result Codes... */
  51. enum {
  52.     collectionItemLockedErr        = -5750,
  53.     collectionItemNotFoundErr    = -5751,
  54.     collectionIndexRangeErr        = -5752,
  55.     collectionVersionErr        = -5753
  56. };
  57.  
  58. /* Convenience constants for functions which optionally return values... */
  59. enum {
  60.     dontWantTag                    = 0L,
  61.     dontWantId                    = 0L,
  62.     dontWantSize                = 0L,
  63.     dontWantAttributes            = 0L,
  64.     dontWantIndex                = 0L,
  65.     dontWantData                = 0L
  66. };
  67.  
  68. /* attributes bits */
  69. enum {
  70.     noCollectionAttributes        = 0x00000000,                    /* no attributes bits set */
  71.     allCollectionAttributes        = 0xFFFFFFFF,                    /* all attributes bits set */
  72.     userCollectionAttributes    = 0x0000FFFF,                    /* user attributes bits */
  73.     defaultCollectionAttributes    = 0x40000000                    /* default attributes - unlocked, persistent */
  74. };
  75.  
  76. /* 
  77.     Attribute bits 0 through 15 (entire low word) are reserved for use by the application.
  78.     Attribute bits 16 through 31 (entire high word) are reserved for use by the Collection Manager.
  79.     Only bits 31 (collectionLockBit) and 30 (collectionPersistenceBit) currently have meaning.
  80. */
  81. enum {
  82.     collectionUser0Bit            = 0,
  83.     collectionUser1Bit            = 1,
  84.     collectionUser2Bit            = 2,
  85.     collectionUser3Bit            = 3,
  86.     collectionUser4Bit            = 4,
  87.     collectionUser5Bit            = 5,
  88.     collectionUser6Bit            = 6,
  89.     collectionUser7Bit            = 7,
  90.     collectionUser8Bit            = 8,
  91.     collectionUser9Bit            = 9,
  92.     collectionUser10Bit            = 10,
  93.     collectionUser11Bit            = 11,
  94.     collectionUser12Bit            = 12,
  95.     collectionUser13Bit            = 13,
  96.     collectionUser14Bit            = 14,
  97.     collectionUser15Bit            = 15,
  98.     collectionReserved0Bit        = 16,
  99.     collectionReserved1Bit        = 17,
  100.     collectionReserved2Bit        = 18,
  101.     collectionReserved3Bit        = 19,
  102.     collectionReserved4Bit        = 20,
  103.     collectionReserved5Bit        = 21,
  104.     collectionReserved6Bit        = 22,
  105.     collectionReserved7Bit        = 23,
  106.     collectionReserved8Bit        = 24,
  107.     collectionReserved9Bit        = 25,
  108.     collectionReserved10Bit        = 26,
  109.     collectionReserved11Bit        = 27,
  110.     collectionReserved12Bit        = 28,
  111.     collectionReserved13Bit        = 29,
  112.     collectionPersistenceBit    = 30,
  113.     collectionLockBit            = 31
  114. };
  115.  
  116. /* attribute masks */
  117. enum {
  118.     collectionUser0Mask            = 1L << collectionUser0Bit,
  119.     collectionUser1Mask            = 1L << collectionUser1Bit,
  120.     collectionUser2Mask            = 1L << collectionUser2Bit,
  121.     collectionUser3Mask            = 1L << collectionUser3Bit,
  122.     collectionUser4Mask            = 1L << collectionUser4Bit,
  123.     collectionUser5Mask            = 1L << collectionUser5Bit,
  124.     collectionUser6Mask            = 1L << collectionUser6Bit,
  125.     collectionUser7Mask            = 1L << collectionUser7Bit,
  126.     collectionUser8Mask            = 1L << collectionUser8Bit,
  127.     collectionUser9Mask            = 1L << collectionUser9Bit,
  128.     collectionUser10Mask        = 1L << collectionUser10Bit,
  129.     collectionUser11Mask        = 1L << collectionUser11Bit,
  130.     collectionUser12Mask        = 1L << collectionUser12Bit,
  131.     collectionUser13Mask        = 1L << collectionUser13Bit,
  132.     collectionUser14Mask        = 1L << collectionUser14Bit,
  133.     collectionUser15Mask        = 1L << collectionUser15Bit,
  134.     collectionReserved0Mask        = 1L << collectionReserved0Bit,
  135.     collectionReserved1Mask        = 1L << collectionReserved1Bit,
  136.     collectionReserved2Mask        = 1L << collectionReserved2Bit,
  137.     collectionReserved3Mask        = 1L << collectionReserved3Bit,
  138.     collectionReserved4Mask        = 1L << collectionReserved4Bit,
  139.     collectionReserved5Mask        = 1L << collectionReserved5Bit,
  140.     collectionReserved6Mask        = 1L << collectionReserved6Bit,
  141.     collectionReserved7Mask        = 1L << collectionReserved7Bit,
  142.     collectionReserved8Mask        = 1L << collectionReserved8Bit,
  143.     collectionReserved9Mask        = 1L << collectionReserved9Bit,
  144.     collectionReserved10Mask    = 1L << collectionReserved10Bit,
  145.     collectionReserved11Mask    = 1L << collectionReserved11Bit,
  146.     collectionReserved12Mask    = 1L << collectionReserved12Bit,
  147.     collectionReserved13Mask    = 1L << collectionReserved13Bit,
  148.     collectionPersistenceMask    = 1L << collectionPersistenceBit,
  149.     collectionLockMask            = 1L << collectionLockBit
  150. };
  151.  
  152. /***********/
  153. /* Types   */
  154. /***********/
  155. /* abstract data type for a collection */
  156. typedef struct PrivateCollectionRecord *Collection;
  157.  
  158. typedef FourCharCode CollectionTag;
  159.  
  160. typedef pascal OSErr (*CollectionFlattenProcPtr)(long size, void *data, void *refCon);
  161. typedef pascal OSErr (*CollectionExceptionProcPtr)(Collection c, OSErr status);
  162.  
  163. #if GENERATINGCFM
  164. typedef UniversalProcPtr CollectionFlattenUPP;
  165. typedef UniversalProcPtr CollectionExceptionUPP;
  166. #else
  167. typedef CollectionFlattenProcPtr CollectionFlattenUPP;
  168. typedef CollectionExceptionProcPtr CollectionExceptionUPP;
  169. #endif
  170.  
  171. enum {
  172.     uppCollectionFlattenProcInfo = kPascalStackBased
  173.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  174.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  175.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(void*)))
  176.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void*))),
  177.     uppCollectionExceptionProcInfo = kPascalStackBased
  178.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  179.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Collection)))
  180.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(OSErr)))
  181. };
  182.  
  183. #if GENERATINGCFM
  184. #define NewCollectionFlattenProc(userRoutine)        \
  185.         (CollectionFlattenUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppCollectionFlattenProcInfo, GetCurrentArchitecture())
  186. #define NewCollectionExceptionProc(userRoutine)        \
  187.         (CollectionExceptionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppCollectionExceptionProcInfo, GetCurrentArchitecture())
  188. #else
  189. #define NewCollectionFlattenProc(userRoutine)        \
  190.         ((CollectionFlattenUPP) (userRoutine))
  191. #define NewCollectionExceptionProc(userRoutine)        \
  192.         ((CollectionExceptionUPP) (userRoutine))
  193. #endif
  194.  
  195. #if GENERATINGCFM
  196. #define CallCollectionFlattenProc(userRoutine, size, data, refCon)        \
  197.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppCollectionFlattenProcInfo, (size), (data), (refCon))
  198. #define CallCollectionExceptionProc(userRoutine, c, status)        \
  199.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppCollectionExceptionProcInfo, (c), (status))
  200. #else
  201. #define CallCollectionFlattenProc(userRoutine, size, data, refCon)        \
  202.         (*(userRoutine))((size), (data), (refCon))
  203. #define CallCollectionExceptionProc(userRoutine, c, status)        \
  204.         (*(userRoutine))((c), (status))
  205. #endif
  206.  
  207. extern pascal Collection NewCollection(void)
  208.  TWOWORDINLINE(0x7000, 0xABF6);
  209. extern pascal void DisposeCollection(Collection c)
  210.  TWOWORDINLINE(0x7001, 0xABF6);
  211. extern pascal Collection CloneCollection(Collection c)
  212.  TWOWORDINLINE(0x7002, 0xABF6);
  213. extern pascal long CountCollectionOwners(Collection c)
  214.  TWOWORDINLINE(0x7003, 0xABF6);
  215. extern pascal Collection CopyCollection(Collection srcCollection, Collection dstCollection)
  216.  TWOWORDINLINE(0x7004, 0xABF6);
  217. extern pascal long GetCollectionDefaultAttributes(Collection c)
  218.  TWOWORDINLINE(0x7005, 0xABF6);
  219. extern pascal void SetCollectionDefaultAttributes(Collection c, long whichAttributes, long newAttributes)
  220.  TWOWORDINLINE(0x7006, 0xABF6);
  221. extern pascal long CountCollectionItems(Collection c)
  222.  TWOWORDINLINE(0x7007, 0xABF6);
  223. extern pascal OSErr AddCollectionItem(Collection c, CollectionTag tag, long id, long itemSize, void *itemData)
  224.  TWOWORDINLINE(0x7008, 0xABF6);
  225. extern pascal OSErr GetCollectionItem(Collection c, CollectionTag tag, long id, long *itemSize, void *itemData)
  226.  TWOWORDINLINE(0x7009, 0xABF6);
  227. extern pascal OSErr RemoveCollectionItem(Collection c, CollectionTag tag, long id)
  228.  TWOWORDINLINE(0x700A, 0xABF6);
  229. extern pascal OSErr SetCollectionItemInfo(Collection c, CollectionTag tag, long id, long whichAttributes, long newAttributes)
  230.  TWOWORDINLINE(0x700B, 0xABF6);
  231. extern pascal OSErr GetCollectionItemInfo(Collection c, CollectionTag tag, long id, long *index, long *itemSize, long *attributes)
  232.  TWOWORDINLINE(0x700C, 0xABF6);
  233. extern pascal OSErr ReplaceIndexedCollectionItem(Collection c, long index, long itemSize, void *itemData)
  234.  TWOWORDINLINE(0x700D, 0xABF6);
  235. extern pascal OSErr GetIndexedCollectionItem(Collection c, long index, long *itemSize, void *itemData)
  236.  TWOWORDINLINE(0x700E, 0xABF6);
  237. extern pascal OSErr RemoveIndexedCollectionItem(Collection c, long index)
  238.  TWOWORDINLINE(0x700F, 0xABF6);
  239. extern pascal OSErr SetIndexedCollectionItemInfo(Collection c, long index, long whichAttributes, long newAttributes)
  240.  TWOWORDINLINE(0x7010, 0xABF6);
  241. extern pascal OSErr GetIndexedCollectionItemInfo(Collection c, long index, CollectionTag *tag, long *id, long *itemSize, long *attributes)
  242.  TWOWORDINLINE(0x7011, 0xABF6);
  243. extern pascal Boolean CollectionTagExists(Collection c, CollectionTag tag)
  244.  TWOWORDINLINE(0x7012, 0xABF6);
  245. extern pascal long CountCollectionTags(Collection c)
  246.  TWOWORDINLINE(0x7013, 0xABF6);
  247. extern pascal OSErr GetIndexedCollectionTag(Collection c, long tagIndex, CollectionTag *tag)
  248.  TWOWORDINLINE(0x7014, 0xABF6);
  249. extern pascal long CountTaggedCollectionItems(Collection c, CollectionTag tag)
  250.  TWOWORDINLINE(0x7015, 0xABF6);
  251. extern pascal OSErr GetTaggedCollectionItem(Collection c, CollectionTag tag, long whichItem, long *itemSize, void *itemData)
  252.  TWOWORDINLINE(0x7016, 0xABF6);
  253. extern pascal OSErr GetTaggedCollectionItemInfo(Collection c, CollectionTag tag, long whichItem, long *id, long *index, long *itemSize, long *attributes)
  254.  TWOWORDINLINE(0x7017, 0xABF6);
  255. extern pascal void PurgeCollection(Collection c, long whichAttributes, long matchingAttributes)
  256.  TWOWORDINLINE(0x7018, 0xABF6);
  257. extern pascal void PurgeCollectionTag(Collection c, CollectionTag tag)
  258.  TWOWORDINLINE(0x7019, 0xABF6);
  259. extern pascal void EmptyCollection(Collection c)
  260.  TWOWORDINLINE(0x701A, 0xABF6);
  261. extern pascal OSErr FlattenCollection(Collection c, CollectionFlattenUPP flattenProc, void *refCon)
  262.  TWOWORDINLINE(0x701B, 0xABF6);
  263. extern pascal OSErr FlattenPartialCollection(Collection c, CollectionFlattenUPP flattenProc, void *refCon, long whichAttributes, long matchingAttributes)
  264.  TWOWORDINLINE(0x701C, 0xABF6);
  265. extern pascal OSErr UnflattenCollection(Collection c, CollectionFlattenUPP flattenProc, void *refCon)
  266.  TWOWORDINLINE(0x701D, 0xABF6);
  267. extern pascal CollectionExceptionUPP GetCollectionExceptionProc(Collection c)
  268.  TWOWORDINLINE(0x701E, 0xABF6);
  269. extern pascal void SetCollectionExceptionProc(Collection c, CollectionExceptionUPP exceptionProc)
  270.  TWOWORDINLINE(0x701F, 0xABF6);
  271. /*****************************************************************************************/
  272. /* Utility Routines for handle-based access...                                                          */
  273. /*****************************************************************************************/
  274. extern pascal Collection GetNewCollection(short collectionID)
  275.  TWOWORDINLINE(0x7020, 0xABF6);
  276. extern pascal OSErr AddCollectionItemHdl(Collection aCollection, CollectionTag tag, long id, Handle itemData)
  277.  TWOWORDINLINE(0x7021, 0xABF6);
  278. extern pascal OSErr GetCollectionItemHdl(Collection aCollection, CollectionTag tag, long id, Handle itemData)
  279.  TWOWORDINLINE(0x7022, 0xABF6);
  280. extern pascal OSErr ReplaceIndexedCollectionItemHdl(Collection aCollection, long index, Handle itemData)
  281.  TWOWORDINLINE(0x7023, 0xABF6);
  282. extern pascal OSErr GetIndexedCollectionItemHdl(Collection aCollection, long index, Handle itemData)
  283.  TWOWORDINLINE(0x7024, 0xABF6);
  284. extern pascal OSErr FlattenCollectionToHdl(Collection aCollection, Handle flattened)
  285.  TWOWORDINLINE(0x7025, 0xABF6);
  286. extern pascal OSErr UnflattenCollectionFromHdl(Collection aCollection, Handle flattened)
  287.  TWOWORDINLINE(0x7026, 0xABF6);
  288.  
  289. #if PRAGMA_IMPORT_SUPPORTED
  290. #pragma import off
  291. #endif
  292.  
  293. #if PRAGMA_ALIGN_SUPPORTED
  294. #pragma options align=reset
  295. #endif
  296.  
  297. #ifdef __cplusplus
  298. }
  299. #endif
  300.  
  301. #endif /* __COLLECTIONS__ */
  302.